<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
	<head>
		<title>封条管理及验证系统--商品新增/修改</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/comm.jsp"%>
		<script language="JavaScript"
			src="<%=request.getContextPath()%>/js/fck_email/fckeditor.js"></script>
		<script>
		$(document).ready(function() {
			$("form *").autohelp("#autohelp");
		});
		  $(document).ready(function(){
		    $('#ok').click(function() { 
		    $('#product_save').submit(); 
		    }) 
		    $("#product_save").validate(
		    );
		  });

		</script>
		<script type="text/javascript">
			window.onload = function()
			{
				var sBasePath = '<%=request.getContextPath()%>/js/fck_email/' ;
				var oFCKeditor = new FCKeditor('content') ;
				oFCKeditor.BasePath	= sBasePath ;
				oFCKeditor.Height = 300 ;
				oFCKeditor.ToolbarSet = 'freemail';
				oFCKeditor.ReplaceTextarea() ;
			}
			
			function preview(imgId, imgName){	
				var picId = document.getElementById(imgId).value;			
			    var fileext=picId.substring(picId.lastIndexOf("."),picId.length);   
			    fileext=fileext.toLowerCase();		
			    $("#fileext").val(fileext);   
			    validateImg(fileext, imgId);			    
			    showimage(imgName, picId);
			}
			
			function validateImg(fileext, imgId){
				if((fileext!='.jpg')&&(fileext!='.gif')&&(fileext!='.jpeg')&&(fileext!='.png')){
					alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 !");   
			        document.getElementById(imgId).focus();  
				}
			}
			
			function showimage(imgName, imgId){
				$(imgName).html('');   
			    var newPreview =$(imgName)[0];     
				var imgDiv = document.createElement("div");
				document.body.appendChild(imgDiv);
				imgDiv.style.width = "140px";    
		        imgDiv.style.height = "110px";   
		        imgDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = scale)";      
		        imgDiv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgId;
				newPreview.appendChild(imgDiv);			
			}
		</script>

		<style type="text/css">
<!--
fieldset {
	padding: 10px;
	margin: 10px;
	width: 270px;
	color: #333;
}

legend {
	color: #06c;
	font-weight: 800;
}
-->
</style>
	<body leftmargin="0" topmargin="0" marginheight="0">
		<s:form name="formpage" action="product_save" namespace="/" method="POST" enctype="multipart/form-data">
			<s:token>
			</s:token>
			<div>
				<s:hidden id="hdfId" name="product.id" value="%{#request.product.id}" />
				<%@ include file="/messages.jsp"%>
				<table  width="750">
					<tr>
						<td align="right" width="120">
							商品名称：
						</td>
						<td>
							<input name="product.productName" type="text" value="${product.productName }"
								maxlength="40" size="30" class="required" title="*必填" />
						</td>
						<td align="right">
							语言：
						</td>
						<td>
							<s:select list="#{'zh_CN':'中文','en':'英文'}" name="product.lang"
								value="#request.product.lang" id="lang" >
							</s:select>
						</td>
					</tr>
					<tr>
						<td align="right">
							有效日期：
						</td>
						<td>
							<input id="dStartdate" name="product.startDate"
								value='<s:date name="#request.product.startDate" format="yyyy-MM-dd" />'
								size="13" class="Wdate" type="text"
								onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'dEnddate\')}'})" />
							至
							<input id="dEnddate" name="product.endDate"
								value='<s:date name="#request.product.endDate" format="yyyy-MM-dd" />'
								size="13" class="Wdate" type="text"
								onFocus="WdatePicker({minDate:'#F{$dp.$D(\'dStartdate\')}'})" />
						</td>
						<td align="right">
							单价：
						</td>
						<td>
							<input name="product.price" type="text" value="${product.price }"
								maxlength="10" size="10" class="required" title="*必填" />
							<s:select list="#{'RMB':'人民币','USD':'美元'}" name="product.currtype"
								value="#request.product.currtype" id="currtype">
							</s:select>
						</td>
					</tr>
					
					<tr>
						<td align="right">
							颜   色：
						</td>
						<td>
							<input name="product.color" type="text" value="${product.color }"
								maxlength="50" size="30" title=";号分隔"/>
						</td>
						<td align="right" >
							最小订购数：
						</td>
						<td>
							<input name="product.minOrderNum" type="text" value="${product.minOrderNum }"
								maxlength="6" size="10"  />
						</td>
					</tr>
					
					<tr>
						<td align="right" >
							型   号：
						</td>
						<td>
							<input name="product.type" type="text" value="${product.type }"
								maxlength="50" size="30"  />
						</td>
						<td align="right" >
							赠送积分：
						</td>
						<td>
							<input name="product.score" type="text" value="${product.score }"
								maxlength="6" size="10"  />
						</td>
					</tr>
					<tr>
						<td align="right" valign="top">
							详细描述：
						</td>
						<td colspan="3">
							<textarea id="content" name="product.detail" rows="6" cols="80">${product.detail }</textarea>
						</td>
					</tr>					
					<tr>
						<td align="right">
							主图片：
						</td>
						<td colspan="3">
						   <s:file title="图片1" name="myFile" size="50" id="myFile1" onchange="preview('myFile1','#imgDiv1')" value="%{#request.product.image1}"></s:file>
							<div id="imgDiv1">
								<img src="${pageContext.request.contextPath}/upload/seal/${product.image1}" style="width: 140px; height: 110px;">
							</div>
						</td>
					</tr>
					
					<tr>
						<td align="right">
							图片2：
						</td>
						<td colspan="3">
							 <s:file title="图片2" name="myFile" size="50" id="myFile2" onchange="preview('myFile2','#imgDiv2')" value="%{#request.product.image2}"></s:file>
							<div id="imgDiv2">
								<img src="${pageContext.request.contextPath}/upload/seal/${product.image2}" style="width: 140px; height: 110px;">
							</div>
						</td>
					</tr>
					<tr>
						<td align="right">
							图片3：
						</td>
						<td colspan="3">
							 <s:file title="图片3" name="myFile" size="50" id="myFile3" onchange="preview('myFile3','#imgDiv3')" value="%{#request.product.image3}"></s:file>
							<div id="imgDiv3">
							<img src="${pageContext.request.contextPath}/upload/seal/${product.image3}" style="width: 140px; height: 110px;">
						</td>
					</tr>
					<tr>
						<td align="right">
							图片4：
						</td>
						<td colspan="3">
							 <s:file title="图片4" name="myFile" size="50" id="myFile4" onchange="preview('myFile4','#imgDiv4')" value="%{#request.product.image4}"></s:file>
							<div id="imgDiv4">
							<img src="${pageContext.request.contextPath}/upload/seal/${product.image4}" style="width: 140px; height: 110px;">
						</td>
					</tr>
					<tr>
						<td align="right">
							图片5：
						</td>
						<td colspan="3">
							<s:file title="图片5" name="myFile" size="50" id="myFile5" onchange="preview('myFile5','#imgDiv5')" value="%{#request.product.image5}"></s:file>
							<div id="imgDiv5">
							<img src="${pageContext.request.contextPath}/upload/seal/${product.image5}" style="width: 140px; height: 110px;">
							
						</td>
					</tr>
					<tr>
						<td colspan="4" align="center">
							<input type="submit" class="button" id="ok" name="ok"
								value=" 保 存 " />
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="button" class="button" id="resets" value=" 返 回 "
								onclick="javascript:history.go(-1)" />
						</td>
					</tr>
				</table>
			</div>
		</s:form>
	</body>
</html>